package test_public;


import org.junit.Assert;
import org.junit.Test;
import datamodel.rucksack.Rucksack;
import datamodel.rucksack.RucksackObject;
import datamodel.tree.linked.LinkedTree;
import datamodel.tree.linked.LinkedTreeNode;
import datamodel.tree.sequential.SequentialTree;
import datamodel.tree.sequential.SequentialTreeNode;

public class TreeEqualsTest {
	
	LinkedTree treeLink;
	SequentialTree treeSeq;
	private  RucksackObject o1 = new RucksackObject(10, 15);
	private  RucksackObject o2 = new RucksackObject(15, 5);
	private  RucksackObject o3 = new RucksackObject(23, 45);

	
	public void ksksks() {

	}
	
	@Test
	public void testTreeEquals(){
		
		treeLink = new LinkedTree();
		Rucksack rucksack = new Rucksack(50);
		treeLink.setCurrentNode(new LinkedTreeNode(rucksack));
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		treeLink.moveToLeftNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		treeLink.moveToLeftNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		rucksack = new Rucksack(50);
		rucksack.insert(o3);
		treeLink.setRightNode(new LinkedTreeNode(rucksack));
		treeLink.moveToParentNode();
		rucksack = new Rucksack(50);
		rucksack.insert(o2);
		treeLink.setRightNode(new LinkedTreeNode(rucksack));
		treeLink.moveToRightNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		rucksack = new Rucksack(50);
		rucksack.insert(o2);
		rucksack.insert(o3);
		treeLink.setRightNode(new LinkedTreeNode(rucksack));
		treeLink.moveToRoot();
		rucksack = new Rucksack(50);
		rucksack.insert(o1);
		treeLink.setRightNode(new LinkedTreeNode(rucksack));
		treeLink.moveToRightNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		treeLink.moveToLeftNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		treeLink.moveToParentNode();
		rucksack = new Rucksack(50);
		rucksack.insert(o1);
		rucksack.insert(o2);
		treeLink.setRightNode(new LinkedTreeNode(rucksack));
		treeLink.moveToRightNode();
		treeLink.setLeftNode(new LinkedTreeNode(rucksack));
		
		//System.out.println(treeLink);
		
		
		
		treeSeq = new SequentialTree();
		Rucksack rucksack1 = new Rucksack(50);
		treeSeq.setCurrentNode(new SequentialTreeNode(rucksack1));
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToLeftNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToLeftNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		rucksack1 = new Rucksack(50);
		rucksack1.insert(o3);
		treeSeq.setRightNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToParentNode();
		rucksack1 = new Rucksack(50);
		rucksack1.insert(o2);
		treeSeq.setRightNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToRightNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		rucksack1 = new Rucksack(50);
		rucksack1.insert(o2);
		rucksack1.insert(o3);
		treeSeq.setRightNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToRoot();
		rucksack1 = new Rucksack(50);
		rucksack1.insert(o1);
		treeSeq.setRightNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToRightNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToLeftNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToParentNode();
		rucksack1 = new Rucksack(50);
		rucksack1.insert(o1);
		rucksack1.insert(o2);
		treeSeq.setRightNode(new SequentialTreeNode(rucksack1));
		treeSeq.moveToRightNode();
		treeSeq.setLeftNode(new SequentialTreeNode(rucksack1));
		
		
		Assert.assertEquals(treeLink, treeSeq);
	}

}
